const axios = require('axios');
const querystring = require('querystring');

async function modifyDns(ip) {
  const { data } = await axios.post(
    'https://dnsapi.cn/Record.Modify',
    querystring.stringify({
      login_token: process.env.loginToken,
      format: 'json',
      lang: 'cn',
      domain: 'youyi.asia',
      sub_domain: 'ssr',
      record_id: process.env.recordId,
      record_type: 'A',
      record_line: '默认',
      value: ip,
      mx: 10,
    }),
  );
  return data;
}

module.exports = { modifyDns };
